<template>
  <div style="display: inline-block;margin-right: 5px;">
    <Modal v-model="modal1"
           title="编辑"
           ok-text="提交"
           :loading="loading"
           @on-ok="handleSubmit('formValidate')">
      <Form ref="formValidate"
            :model="formValidate"
            :label-width="80">
        <FormItem label="昵称">
          <Input v-model="formValidate.NickName"
                 placeholder="请输入您的昵称" />
        </FormItem>
        <FormItem label="密码">
          <Input v-model="formValidate.Pwd"
                 type="password"
                 placeholder="请输入您的密码" />
        </FormItem>
        <FormItem label="用户类型"
                  prop="UserType">
          <Select v-model="formValidate.UserType"
                  style="width: 150px">
            <Option v-for="item in UserType"
                    :value="item.number"
                    :key="item.number">{{ item.text }}</Option>
          </Select>
        </FormItem>
        <FormItem label="用户状态"
                  prop="IsDisable">
          <Select v-model="formValidate.IsDisable"
                  style="width: 150px">
            <Option v-for="item in IsDisable"
                    :value="item.number"
                    :key="item.number">{{ item.text }}</Option>
          </Select>
        </FormItem>
        <FormItem label="注册来源">
          <Select v-model="formValidate.RegistSource"
                  style="width: 150px">
            <Option v-for="item in RegistSource"
                    :value="item"
                    :key="item">{{ item }}</Option>
          </Select>
        </FormItem>
        <FormItem label="每天奖励额">
          <Input v-model="formValidate.EveryDayReward"
                 placeholder="请输入每天奖励额" />
        </FormItem>
        <FormItem label="用户积分">
          <Input v-model="formValidate.Userintegral"
                 placeholder="请输入用户积分" />
        </FormItem>
        <FormItem label="奖励额">
          <Input v-model="formValidate.RewardQuota"
                 placeholder="请输入奖励额" />
        </FormItem>
      </Form>
    </Modal>
  </div>
</template>

<script>
import { getGoodsClassDetail } from '@/api/goods'
export default {
  name: 'edit',
  data () {
    return {
      modal1: false,
      loading: true,
      RecIs: [
        {
          number: 0,
          text: '不推荐'
        },
        {
          number: 1,
          text: '猜你喜欢'
        },
        {
          number: 2,
          text: '可能还喜欢'
        }
      ],
      formValidate: {},
      AutoId: ''
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
      this.modal1 = false
      this.loading = true
      this.formValidate = {}
      this.editData = {}
      this.handleReset('formValidate')
    },
    getItem (id) {
      this.handleReset('formValidate')
      this.AutoId = id
      getGoodsClassDetail({ AutoId: id }).then(res => {
        if (res.data.success) {
          this.formValidate = res.data.data
        } else {
          this.$Message.info(res.data.msg)
        }
      }).then(() => {
        this.modal1 = true
      })
    },
    handleSubmit (name) {
      this.formValidate.SysUserId = localStorage.getItem('userId')
      this.formValidate.UserID = this.AutoId
      editUserDetail(this.formValidate).then(res => {
        if (res.data.success) {
          this.modal1 = false
          this.loading = true
          this.$Message.info('编辑成功!')
        } else {
          this.modal1 = true
          this.loading = false
          this.$Message.info('编辑失败!')
        }
      }).then(() => {
        this.$emit('getList')
      })
    },
    // 重置表单
    handleReset (name) {
      this.$refs[name].resetFields()
    }
  }
}
</script>

<style lang="less" scoped>
</style>
